<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>闰年检测</title>
        <style type="text/css">
            h3 {
                text-align: center;
            }
            div {
                text-align: center;
            }
        </style>
    </head>
    <body>
        <h3>输入一个年份判断是否为闰年</h3>
        <div>
            <input type="text" name="txtYear" id="txtYear">
            <input type = "button" value ="判断" onclick="testLeapYear()">
        </div>
        <script>
            function testLeapYear() {
                let year = document.getElementById("txtYear").value;
                if(year%100===0){
                    if(year%400===0) window.alert("这是闰年");
                    else window.alert("这不是闰年");
                }
                else if(year%10===0){
                    if(year%40===0) window.alert("这是闰年");
                    else window.alert("这不是闰年");
                }
                else {
                    if(year%4===0) window.alert("这是闰年");
                    else window.alert("这不是闰年");
                }
            }
        </script>
    </body>
</html>